//
//  JMJLoginTextField.m
//  JinMaJiaDemo
//
//  Created by GripMeMory on 16/1/11.
//  Copyright © 2016年 GripMeMory. All rights reserved.
//

#import "JMJLoginTextField.h"

#define kLeftMargin 10
#define kTopMargin 5

@implementation JMJLoginTextField

- (CGRect)leftViewRectForBounds:(CGRect)bounds{
    CGRect rect = bounds;
    return CGRectMake(kLeftMargin, kTopMargin, rect.size.height - 2 *  kTopMargin, rect.size.height - 2 * kTopMargin);
}

- (CGRect)editingRectForBounds:(CGRect)bounds{
    CGRect rect = bounds;
    return CGRectMake(self.leftView.right + kLeftMargin, 0, rect.size.width - self.leftView.right, rect.size.height);
}

- (CGRect)placeholderRectForBounds:(CGRect)bounds{
    CGRect rect = bounds;
    return CGRectMake(self.leftView.right + kLeftMargin, 0, rect.size.width - self.leftView.right, rect.size.height);
}

- (CGRect)textRectForBounds:(CGRect)bounds{
    CGRect rect = bounds;
    return CGRectMake(self.leftView.right + kLeftMargin, 0, rect.size.width - self.leftView.right, rect.size.height);
}

- (CGRect)rightViewRectForBounds:(CGRect)bounds{
    CGRect rect = bounds;
    return CGRectMake(rect.size.width - 2 * kLeftMargin - (self.height - 2 * kTopMargin), kTopMargin , (self.height - 2 * kTopMargin), self.height - 2 * kTopMargin);
}

@end

@implementation JMJNormalTextField

- (CGRect)editingRectForBounds:(CGRect)bounds{
    CGRect rect = bounds;
    return CGRectMake(kLeftMargin, 0, rect.size.width - self.leftView.right, rect.size.height);
}

- (CGRect)placeholderRectForBounds:(CGRect)bounds{
    CGRect rect = bounds;
    return CGRectMake(kLeftMargin, 0, rect.size.width - self.leftView.right, rect.size.height);
}

- (CGRect)textRectForBounds:(CGRect)bounds{
    CGRect rect = bounds;
    return CGRectMake(kLeftMargin, 0, rect.size.width - self.leftView.right, rect.size.height);
}

@end
